﻿using System.Windows.Forms;
using AMatysiak.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace AMatysiakTest.Controls
{
    [TestClass]
    public class DataGridViewCalendarCellTest
    {
        [TestMethod]
        public void createColumn()
        {
            DataGridView grid = new DataGridView();
            grid.Columns.Add(new DataGridViewCalendarColumn());
            Type type = grid.Columns[0].GetType();

            Assert.AreEqual(typeof(DataGridViewCalendarColumn), type);
        }

        [TestMethod]
        public void createCell()
        {
            DataGridView grid = new DataGridView();
            grid.Columns.Add(new DataGridViewCalendarColumn());
            grid.Rows.Add(DateTime.Now.Date);
            Type type = grid.Rows[0].Cells[0].GetType();

            Assert.AreEqual(typeof(DataGridViewCalendarCell), type);
        }

        [TestMethod]
        public void checkValueType()
        {
            DataGridView grid = new DataGridView();
            grid.Columns.Add(new DataGridViewCalendarColumn());
            grid.Rows.Add(DateTime.Now.Date);
            Type type = grid.Rows[0].Cells[0].Value.GetType();

            Assert.AreEqual(typeof(DateTime), type);
        }

        [TestMethod]
        public void changeCell()
        {
            DataGridView grid = new DataGridView();
            grid.Columns.Add(new DataGridViewCalendarColumn());
            grid.Rows.Add(DateTime.Now.Date);
            grid.Rows[0].Cells[0].Value = DateTime.Now.AddDays(1).Date;
            DateTime dt = (DateTime)grid.Rows[0].Cells[0].Value;

            Assert.AreEqual(DateTime.Now.AddDays(1).Date, dt);
        }
    }
}
